# Contributor: Aleks Bunin <alpinelinux@compuix.com>
# Maintainer: Aleks Bunin <alpinelinux@compuix.com>
pkgname=delta
pkgver=0.16.5
pkgrel=1
pkgdesc="Syntax-highlighting pager for git and diff output"
url="https://github.com/dandavison/delta"
license="MIT"
# s390x: incompatible with nix crate
arch="all !s390x"
makedepends="
	cargo
	cargo-auditable
	libgit2-dev
	oniguruma-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/dandavison/delta/archive/refs/tags/$pkgver.tar.gz
	libgit2.patch
	"
options="net"

# secfixes:
#   0.13.0-r0:
#     - CVE-2022-24713

export RUSTONIG_SYSTEM_LIBONIG="true"

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/delta -t "$pkgdir"/usr/bin/
}

sha512sums="
76475159ad659261dea3f60e5ee340d64f16031b59387602a6b962f854e5c88e5ad1613715ea0581197d8b829c75326d25c9550d0899957a0ce7e4dd5d3046a9  delta-0.16.5.tar.gz
b05bb0b1a75d9fd3c050319ab4be20e99a6379c0184ac4be087ff51fd17571c1bfc3d6b724b7848d1a06482178eafdd533cb4783d1adc086c3ade08edf9ae512  libgit2.patch
"
